package com.zhonghui.wms.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.zhonghui.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.zhonghui.wms.domain.WmsWarehouseSeat;
import com.zhonghui.wms.mapper.WmsWarehouseAreaMapper;
import com.zhonghui.wms.domain.WmsWarehouseArea;
import com.zhonghui.wms.service.IWmsWarehouseAreaService;

/**
 * 库区Service业务层处理
 *
 * @author zhonghui
 * @date 2022-05-26
 */
@Service
public class WmsWarehouseAreaServiceImpl implements IWmsWarehouseAreaService
{
    @Autowired
    private WmsWarehouseAreaMapper wmsWarehouseAreaMapper;

    /**
     * 查询库区
     *
     * @param id 库区主键
     * @return 库区
     */
    @Override
    public WmsWarehouseArea selectWmsWarehouseAreaById(Long id)
    {
        return wmsWarehouseAreaMapper.selectWmsWarehouseAreaById(id);
    }

    /**
     * 查询库区列表
     *
     * @param wmsWarehouseArea 库区
     * @return 库区
     */
    @Override
    public List<WmsWarehouseArea> selectWmsWarehouseAreaList(WmsWarehouseArea wmsWarehouseArea)
    {
        return wmsWarehouseAreaMapper.selectWmsWarehouseAreaList(wmsWarehouseArea);
    }

    /**
     * 新增库区
     *
     * @param wmsWarehouseArea 库区
     * @return 结果
     */
    @Transactional
    @Override
    public int insertWmsWarehouseArea(WmsWarehouseArea wmsWarehouseArea)
    {
        int rows = wmsWarehouseAreaMapper.insertWmsWarehouseArea(wmsWarehouseArea);
        return rows;
    }

    /**
     * 修改库区
     *
     * @param wmsWarehouseArea 库区
     * @return 结果
     */
    @Transactional
    @Override
    public int updateWmsWarehouseArea(WmsWarehouseArea wmsWarehouseArea)
    {
        return wmsWarehouseAreaMapper.updateWmsWarehouseArea(wmsWarehouseArea);
    }

    /**
     * 批量删除库区
     *
     * @param ids 需要删除的库区主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteWmsWarehouseAreaByIds(Long[] ids)
    {
        wmsWarehouseAreaMapper.deleteWmsWarehouseSeatByWarehouseAreaIds(ids);
        return wmsWarehouseAreaMapper.deleteWmsWarehouseAreaByIds(ids);
    }

    /**
     * 删除库区信息
     *
     * @param id 库区主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteWmsWarehouseAreaById(Long id)
    {
        wmsWarehouseAreaMapper.deleteWmsWarehouseSeatByWarehouseAreaId(id);
        return wmsWarehouseAreaMapper.deleteWmsWarehouseAreaById(id);
    }
}
